<?php

namespace app\admin\validate;
use think\validate;

class Category extends validate
{


    protected $rule =   [
        // 'name'  => 'checkTitle',
    ];


    protected $message  =   [

        'name.length'      => ['code' => 4023, 'msg' => '长度是1到6位'],
        // 'name.unique'      => ['code' => 4012, 'msg' => '名称已经存在'],

    ];


    // 自定义验证规则
    protected function checkTitle($value,$rule,$data=[])
    {
        $rule = ['name'    => 'unique:category,name^type='.$data['type']];
        return $this->check($data,$rule);
    }

}